//引包
document.write("<script type='text/javascript' src='js/createObject.js'></script>");

window.onload=function(){
	
	document.getElementById("index-ok").onclick=function(){
		if(document.getElementById("index-user").value!=null&&document.getElementById("index-user").value!=""){
		
			if(document.getElementById("index-pas").value!=null&&document.getElementById("index-pas").value!=""){
		
				var xmlRequest = createXHQ();
				
				xmlRequest.open("POST","index.html");
				
				xmlRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				
				var parameter = "username=" + document.getElementById("index-user").value +"&password=" +document.getElementById("index-pas").value;
				
				xmlRequest.send(parameter);
				
				xmlRequest.onreadystatechange = function(){
					if(xmlRequest.readyState===4){
						if(xmlRequest.status===200){
							var ret = xmlRequest.responseText;
							var resultJ = JSON.parse(ret);
							
							alert(resultJ);
						}else{
							alert("错误代码："+xmlRequest.status);
						}
					}
				}
				
			}else{
					alert("密码不能为空！");
			}
			
		}else{
			
			alert("用户名不能为空：");
		}

	}
	
}